package nju.eai.seller.server;

import java.sql.SQLException;

import nju.eai.corba.sellerSystem.Date;
import nju.eai.corba.sellerSystem.OrderBill;
import nju.eai.corba.sellerSystem.ProductInfo;
import nju.eai.corba.sellerSystem.PurchaseResponse;
import nju.eai.corba.sellerSystem.SystemB;
import nju.eai.corba.sellerSystem.SystemBPOA;
import nju.eai.seller.main.SellerCore;

public class SellerImplement extends SystemBPOA {
	private SellerCore sc;
	
	public SellerImplement(){
		this.sc =  new SellerCore();
	}
	@Override
	public OrderBill ackPurchase(String orderno) {
		// TODO Auto-generated method stub
		try {
			return sc.ackPurchase(orderno);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public boolean affirm(String purchaseNo) {
		// TODO Auto-generated method stub
		try {
			return sc.affirm(purchaseNo);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public void askToDeliver(String purchaseNo) {
		// TODO Auto-generated method stub
		//
		try {
			sc.askToDeliver(purchaseNo, true);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@Override
	public void notifyDealDone(String purchaseNo) {
		// TODO Auto-generated method stub
		try {
			sc.notifyDealDone(purchaseNo);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public PurchaseResponse requestPurchase(String pid, int quantity,
			Date deliveryDate) {
		// TODO Auto-generated method stub
		try {
			return sc.requestPurchase(pid, quantity, deliveryDate);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public ProductInfo sentPurchaseExpection(String type, double expectedPrice) {
		// TODO Auto-generated method stub
		return sc.sentPurchaseExpection(type, expectedPrice);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SellerImplement si =  new SellerImplement();
		si.askToDeliver("dddd");
	}

}
